is_sunny_day = True

is_raining_day = False

print(f"is_sunny_day: {is_sunny_day}")
print(f"is_raining_day: {is_raining_day}")

#运算
print(f"not is_sunny_day = {not is_sunny_day}")
print(f"not is_raining_day = {not is_raining_day}")
print(f"is_sunny_day: {is_sunny_day==1}")
print(f"is_raining_day: {is_raining_day==0}")

# 输出True与1是否相等
print(f"True == 1: {True == 1}")      # True
# 输出False与0是否相等
print(f"False == 0: {False == 0}")    # True
# 输出True加True的结果
print(f"True + True: {True + True}")  # 2
# 输出True乘以10的结果
print(f"True * 10: {True * 10}")      # 10
# 输出False乘以10的结果
print(f"False * 10: {False * 10}")    # 0



# 逻辑运算
a, b = True, False

print("逻辑运算:")
print(f"{a} and {b} = {a and b}")     # False
print(f"{a} or {b} = {a or b}")       # True
print(f"not {a} = {not a}")           # False
print(f"not {b} = {not b}")           # True

# 真值表
print("\n真值表:")
print("AND运算:")
print(f"True and True = {True and True}")     # True
print(f"True and False = {True and False}")   # False
print(f"False and True = {False and True}")   # False
print(f"False and False = {False and False}") # False

print("\nOR运算:")
print(f"True or True = {True or True}")       # True
print(f"True or False = {True or False}")     # True
print(f"False or True = {False or True}")     # True
print(f"False or False = {False or False}")   # False

print("\nNOT运算:")
print(f"not True = {not True}")               # False
print(f"not False = {not False}")             # True



def expensive_operation():
    print("执行了耗时操作!")
    return True

print("短路特性:")
# and 短路：第一个为False时，不计算第二个
result1 = False and expensive_operation()  # 不会打印
print(f"False and 耗时操作: {result1}")

# or 短路：第一个为True时，不计算第二个
result2 = True or expensive_operation()    # 不会打印
print(f"True or 耗时操作: {result2}")

# 会执行的情况
print("会执行耗时操作的情况:")
result3 = True and expensive_operation()   # 会打印
print(f"True and 耗时操作: {result3}")
result4 = False or expensive_operation()   # 会打印
print(f"False or 耗时操作: {result4}")



def printEvenNumbers(num):
    for _num in range(0,num+1):
        if _num & 1 ==0:
            print(f"{_num}这个数是偶数")
        else:
            print(f"{_num}这个数是奇数")

printEvenNumbers(10)